package com.itheima.enable;

import com.itheima.enableother.config.EnableUser;
import com.itheima.enableother.config.MyImportBeanDefinitionRegistrar;
import com.itheima.enableother.config.MyImportSelector;
import com.itheima.enableother.config.UserConfig;
import com.itheima.enableother.domain.Role;
import com.itheima.enableother.domain.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import redis.clients.jedis.Jedis;

import java.util.Map;

/**
 * ComponentScan：扫描包，当前包及其子包
 * com.itheima.enable
 * com.itheima.enableother.config
 *
 * 1.使用@ComponentScan，扫描com.itheima.enableother.config
 * 2.使用@Import注解，导入配置类
 * 3.使用@Enable注解
 */


/**
 * @import注解
 * 1.导入Bean
 * 2.导入配置类
 * 3.导入 ImportSelector 实现类
 * 4.导入 ImportBeanDefinitionRegistrar 实现类
 *
 */



//@ComponentScan("com.itheima.enableother.config")
//@Import(UserConfig.class)
//@EnableUser
//@Import(User.class)
//@Import(UserConfig.class)
//@Import(MyImportSelector.class)
//@Import(MyImportBeanDefinitionRegistrar.class)


@SpringBootApplication
public class SpringbootEnableApplication {

	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(SpringbootEnableApplication.class, args);

		/*Object user = context.getBean("user");
		System.out.println(user);*/

		/*User user = context.getBean(User.class);
		System.out.println(user);*/

		/*Role role = context.getBean(Role.class);
		System.out.println(role);*/

		/*Map<String, User> map = context.getBeansOfType(User.class);
		System.out.println(map);*/

		/*Object user = context.getBean("com.itheima.enableother.domain.User");
		System.out.println(user);*/

		Jedis jedis = (Jedis) context.getBean("jedis");
		System.out.println(jedis);

		jedis.set("mykey", "itheima");

		String value = jedis.get("mykey");
		System.out.println(value);

	}

	/*@Bean
	public Jedis jedis(){
		return new Jedis("localhost", 6379);
	}*/

}
